/**api接口，接口的危险命名兼容 */
const basicService = '/SvjDcWebService/Service.asmx/';
const api = {
  SELECTSQL: basicService + 'SelectDataBase',// select sql
  UPDATESQL: basicService + 'UpdateDataBase',// update sql

  
  GETWORKSDSG: basicService + 'WorksMessageSearch',// 根据作品id查作品和设计师
  APPLYGAME: basicService + 'DesignerCompetition',// 设计师报名
  GETPRIZEWORKSPAGED: basicService + 'WinningWorks',// 分页查询获奖作品
  VOTEWORKS: basicService + 'WorksVote',// 作品投票
  CLICKWORKS: basicService + 'WorksClick',// 作品投票
}

/**调整过的接口 */
Object.assign(api, {
  GETCURGAME: basicService + 'InGameBasics',// 获得当前大赛
  GETPREGAMES: basicService + 'GameBasics',// 获得所有生效大赛
  GETTAGSDATA: basicService + 'GetMainSubLabelData',// 获得标签数据
  GETGAMEDETAILBYID: basicService + 'GameDetailBasics',// 获得大赛奖项数据 by 大赛id
  REGISTER: basicService + 'DesignerRegistration', // 注册大赛帐号
  LOGIN: basicService + 'DesignerLogin',// 登录
  GETWORKSDATAPAGE: basicService + 'DesignerWorksSearch',// 个人中心作品分页查询
  GETPRIZEPAGEBYID: basicService + 'DesignerWinningWorks',// 分页查询设计师获奖
  GETDESIGNERBYID: basicService + 'SearchDesigner',// 查询一个设计师 by desingerID
  CHANGEPWD: basicService + 'ChangePasswordDesigner',// 修改密码
  ENTRYGAME: basicService + 'WorksCompetition',// 选择参赛
  UPLOADWORKS: basicService + 'WorksUplod',// 作品上传
  GETWORKSLISTBYMPAGE: basicService + 'WorkCategorySearch',// 分页分类查询作品
  GETHOMEWORKSLISTBYMPAGE: basicService + 'HomeWorkCategorySearch',// 分页分类查询作品
  GETAdminWORKSLISTBYMPAGE: basicService + 'AdminWorkCategorySearch',// 优秀案例分页分类查询作品
  PROVINCESDATA: basicService + 'PCData',// 省市数据
  GETDESIGNERPAGED: basicService + 'DesignerPagingQuery',// 分页查询已报名设计师
  GETHOMECARS: basicService + 'GameIndexImages',// 轮播图接口
  GetAdminSubLabelData:basicService+'GetAdminSubLabelData',
});

/**环境适配 */
const env = process.env.NODE_ENV;
if(env === 'production') {
  Object.assign(api, { UPLOADIMG: 'http://14.215.50.212/upload/gopost' });
} else {// development
  // Object.assign(api, { UPLOADIMG: 'http://127.0.0.1:9090/upload/gopost' });
  Object.assign(api, { UPLOADIMG: 'http://14.215.50.212/upload/gopost' });
}

/**
 * api参数结构体、类实体结构体
 * 用于复杂的参数结构体
 * 用于实体响应式处理
 */
const structure = {

  /**大赛信息结构体 */
  CURGAME({
    ID = '',
    name = '',
    desc = '',
    stageName = '',
    isEffectName = '',
    statusName = '',
    startOn = '',
    endOn = ''
  } = {}) {
    return {
      ID, name, desc, stageName, isEffectName, statusName, startOn, endOn
    }
  },


  /**查询设计师结构体 */
  GETADESIGNER({
    headImagePath = '',
    SvjiaNo = '',
    address = '',
    birthdate = '',
    city = '',
    designerID = '',
    email = '',
    introduction = '',
    isRecommend = '',
    location = '',
    loginID = '',
    name = '',
    province = '',
    sex = '',
    sexName = '',
    storeMainPic = '',
    storeName = '',
    storePic = '',
    tel = ''
  } = {}) {
    return {
      headImagePath, SvjiaNo, address, birthdate, city, 
      designerID, email, introduction, isRecommend, location,
      loginID, name, province, sex, sexName, storeMainPic, storeName, storePic, tel
    }
  },

  /**注册结构体 */
  REGISTER({
    password = '',
    name = '',
    sex = '',
    birthdate = '',
    SvjiaNo = '',
    tel = '',
    email = '',
    introduction = '',
    storeName = '',
    headImagePath = '',
    storeMainPic = '',
    storePic = '',
    province = '',
    city = '',
    address = '',
    location = ''
  } = {}) {
    return {
      password, name, sex, birthdate, SvjiaNo, tel, email,
      introduction, storeName, headImagePath, storeMainPic,
      storePic, province, city, address, location
    }
  },

  /**作品上传结构体 */
  UPLOADWORKS({
    designerID = '',
    name = '',
    mainPic = '',
    introduction = '',
    panorama = '',
    panoramaUrl = '',
    status = '',
    reason = '',
    ownerName = '',
    ownerAddress = '',
    ownerTel = '',
    isRecommend = '',
    location = '',
    worksPic = [],
    worksTag = []
  } = {}) {
    return {
      designerID, name, mainPic, introduction, panorama, panoramaUrl,
      status, reason, ownerName, ownerAddress, ownerTel, isRecommend,
      location, worksPic, worksTag
    }
  },

  /**作品查询结构 */
  WORKSSEARCH({
    ID = '',
    designerID = '',
    name = '',
    mainPic = '',
    introduction = '',
    createdOn = '',
    panorama = '',
    panoramaUrl = '',
    status = '',
    reason = '',
    ownerName = '',
    ownerAddress = '',
    ownerTel = '',
    isRecommend = '',
    oper = ''
  } = {}) {
    return {
      ID, designerID, name, mainPic, introduction, createdOn, panorama, oper,
      panoramaUrl, status, reason, ownerName, ownerAddress, ownerTel, isRecommend
    }
  }
}


export default {
  install(Vue, options) {
    Vue.prototype.api = api;
    Vue.prototype.structure = structure;
  }
}